var findArr = function (arr, target) {
    let start, end;
    start = end = 0;
    let sum = 0;
    let len = arr.length;
    let res = Infinity;

    while (end < len) {
        sum += arr[end];
        while (sum >= target) {
            res = Math.min(res, end - start + 1);
            sum -= arr[start];
            start++;
        }
        end++;
    }
    return res === Infinity ? 0 : res;
}

const arr = [2, 3, 1, 2, 4, 3];
console.log(findArr(arr, 7));
